package com.ssm.zyn.service.impl;

import com.ssm.zyn.dao.TesttableMapper;
import com.ssm.zyn.eo.TestTableEOpage;
import com.ssm.zyn.model.TestTable;
import com.ssm.zyn.service.Testtableservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TestTableServiceImpl implements Testtableservice {
    @Autowired
    private TesttableMapper testtableMapper;
    @Override
    public int AddTesttable(TestTable testTable) {
        int returnInt=0;
        int testTableExam=testtableMapper.getExamContentCount(testTable.getExamcontent());
        if (testTableExam<1){
            int addTesttableInt=testtableMapper.insertTesttable(testTable);
            returnInt=addTesttableInt;
        }else {
            returnInt = -1;//有相同的内容
        }
        return returnInt;
    }

    @Override
    public int UpdateTesttable(TestTable testTable) {
        int isUpdate=0;
        try {
            isUpdate = testtableMapper.updatetesttable(testTable);
        } catch (Exception e) {
            isUpdate = -1;
            //打印更新时报错的情况
            System.out.println("更新角色信息时执行SQL报错的原因为"+e.getMessage());
        }
        return isUpdate;
    }

    @Override
    public int DeleteTesttable(int qid) {
        int delTesttable=0;
        try{
            delTesttable=testtableMapper.delTesttable(qid);
        }catch (Exception e){
            delTesttable=-1;
            System.out.println("删除班级信息时执行SQL报错，信息为"+e.getMessage());
        }
        return delTesttable;
    }

    @Override
    public List<TestTableEOpage> getWhereAll(TestTableEOpage testTableEOpage) {
        List<TestTableEOpage> listTestTable=testtableMapper.getWhereAll(testTableEOpage);
        return listTestTable;
    }


}
